package com.dacool.http;

import java.util.HashMap;

import org.json.JSONException;
import org.json.JSONObject;

import com.dacool.config.Config;

public class UpdateAddressRequest extends BaseRequest {

	/**
	 * memberId:”61234”,”address”:”望京桥月亮家园32楼2106”,”region”:”北京市 朝阳区”,
	 * deliveryMan：”送货人张三”,mobile:”13632567896”, remark:”备注节日送货”
	 */

	private String address;
	private String region;
	private String deliveryMan;
	private String mobile;
	private String remark;
	private int id;
	private int shipRegionId;
	
	public UpdateAddressRequest setShipRegionId(int shipRegionId) {
		this.shipRegionId = shipRegionId;
		return this;
	}

	@Override
	protected String url() {
		// TODO Auto-generated method stub
		return "updateAddress.jsn";
	}

	/**
	 * {"name":"张三","area":"北京市-朝阳区","addr":"三元桥","zip":"100000","mobile":
	 * "13555555555","day":"工作日","defAddr":0} 
	 */
	@Override
	protected void generateParams(HashMap<String, Object> map) {
		// TODO Auto-generated method stub
		// map.put("memberId", memberId);
		JSONObject object = new JSONObject();
		try {
			object.put("name", deliveryMan);
			object.put("addr", address);
			object.put("mobile", mobile);
			object.put("area", region);
			object.put("shipRegionId", shipRegionId);
			
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		map.put("addressId", id);
		map.put("address", object.toString());
	}

	public UpdateAddressRequest setId(int id) {
		this.id = id;
		return this;
	}

	public UpdateAddressRequest setAddress(String address) {
		this.address = address;
		return this;
	}

	public UpdateAddressRequest setRegion(String region) {
		this.region = region;
		return this;
	}

	public UpdateAddressRequest setDeliveryMan(String deliveryMan) {
		this.deliveryMan = deliveryMan;
		return this;
	}

	public UpdateAddressRequest setMobile(String mobile) {
		this.mobile = mobile;
		return this;
	}

	public UpdateAddressRequest setRemark(String remark) {
		this.remark = remark;
		return this;
	}

}
